package passwordManage;

public class Demo {

	public static void main(String[] args) throws InvalidMenuOptionException{
		Function fc=new Function();
		while(true) {
			System.out.println("================================");
			System.out.println("      欢迎使用密码管理系统      ");
			System.out.println("================================");
			System.out.println("           请选择操作：         ");
			System.out.println("           1.加密               ");
			System.out.println("           2.解密               ");
			System.out.println("           3.判断密码强度       ");
			System.out.println("           4.密码生成           ");
			System.out.println("           5.退出               ");
			System.out.println("================================");
			System.out.println("请输入选项序号：");
			int option=KS.scanInt();
			switch(option) {
			 case 1:
				System.out.println("请输入要加密的数字密码：");
				String encryptedPassword=KS.scan();
			    try {
			    	fc.checkPassword(encryptedPassword);
			    	System.out.println("加密后的结果为："+fc.encrypt(encryptedPassword));
			    }catch(InvalidPasswordException e) {
			    	System.out.println(e.getMessage());			    	 
			    }		
				break;
			case 2:
				System.out.println("请输入要解密的数字密码：");
				String decryptedPassword=KS.scan();
				try {
					fc.checkPassword(decryptedPassword);
			    	System.out.println("解密后的结果为："+fc.decrypt(decryptedPassword));
			    }catch(InvalidPasswordException e) {
			    	System.out.println(e.getMessage());			    	 
			    }
			    break;
			case 3:
				System.out.println("请输入需要判断强度的密码：");
				String passwordToCheck=KS.scan();
				try {
			    	fc.checkPassword(passwordToCheck);
			    	System.out.println("该密码为："+fc.checkPasswordStrength(passwordToCheck));
			    }catch(InvalidPasswordException e) {
			    	System.out.println(e.getMessage()); 
			    }
		        break;
			case 4:
				System.out.println("请输入随机生成密码的长度：");
				int length=KS.scanInt();
				System.out.println("生成的密码为："+ fc.generatePassword(length));
				break;
			case 5:
				System.out.println("成功退出密码管理系统！");
				System.exit(0);
			default:
				try {
			        fc.handleMenuOption(option);
			    } catch (InvalidMenuOptionException e) {
			        System.out.println(e.getMessage());
			    }
			}
		}
        
	}
    
}

























		


